#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2019/2/25 16:34
@desc
"""
import threading
import subprocess


class MyClass():
    def __init__(self):
        self.stdout = None
        self.stderr = None

    def run(self, num, cdl):
        p = subprocess.Popen(r'java -jar D:\iProject\mini\target\mini-1.0-SNAPSHOT.jar'.split(),
                             shell=False,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        print("subProcess-" + str(num))
        cdl.countDown()
        self.stdout, self.stderr = p.communicate()
        return self.stdout, self.stderr

    def run_no_cdl(self, num):
        p = subprocess.Popen(r'java -jar D:\iProject\mini\target\mini-1.0-SNAPSHOT.jar'.split(),
                             shell=False,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        print("subProcess-" + str(num))
        self.stdout, self.stderr = p.communicate()
        return self.stdout, self.stderr

